package com.itfreer.demo.configuration;

import javax.servlet.MultipartConfigElement;

import com.itfreer.file.client.TencentYunCosPara;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.itfreer.file.service.kindeditor.KindeditorPara;

/**
 * 文件服务器配置
 */
@Configuration
public class FileConfiguration {

	// 腾讯COS测试用
	private final String SECRET_ID = "AKIDN2gBU1DWUDj064veFerpX1EEQLzNIKvd";
	private final String SECRET_KEY = "auyrToJXz3fEZeU4PaZLq42oJXaS9YhZ";
	private final String APP_ID = "1300278090";

	/**
	 * 文件上传配置
	 * 
	 * @return
	 */
	@SuppressWarnings("deprecation")
	@Bean
	public MultipartConfigElement multipartConfigElement() {
		MultipartConfigFactory factory = new MultipartConfigFactory();
		// 单个数据大小
		factory.setMaxFileSize("10MB");
		/// 总上传数据大小
		factory.setMaxRequestSize("100MB");
		return factory.createMultipartConfig();
	}
	
	/**
	 * kindeditor的附件下载地址前缀
	 * @return
	 */
	@Bean
	public KindeditorPara kindeditorPara() {
		KindeditorPara para = new KindeditorPara();
		return para;
	}

	@Bean
	public TencentYunCosPara tencentYunCosPara() {
		TencentYunCosPara para = new TencentYunCosPara();
		para.setSecretId(SECRET_ID);
		para.setSecretKey(SECRET_KEY);
		para.setAppId(APP_ID);
		para.setRegion("ap-chengdu");
		return para;
	}
}
